SPB Git
750 B · 13 lines typescript
1import { z } from "zod";2import { guarded, json, body } from "@/lib/api";3import { branchConversation, activateBranch } from "@/lib/chat/store";45/** POST {messageId} → fork into a new conversation; POST {activate: messageId} → switch active sibling in place. */6export const POST = guarded<{ id: string }>(async (req, { params }) => {7  const b = await body(req, z.object({ messageId: z.string().optional(), activate: z.string().optional() }));8  if (b.activate) { await activateBranch(params.id, b.activate); return json({ ok: true }); }9  if (!b.messageId) return json({ error: "messageId requis" }, { status: 400 });10  const conv = await branchConversation(params.id, b.messageId);11  return json({ conversation: conv }, { status: 201 });12});13
Files · main
Menu

Theme